package com.csd.service.impl;/*
 * Description:
 * User:Hello，Mr.Zhou
 * Date:2020-12-24
 * Time:15:34
 *
 * */

import com.csd.dao.OrderDao;
import com.csd.pojo.Order;
import com.csd.pojo.OrderItems;
import com.csd.pojo.SysOrder;
import com.csd.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired(required = false)
    private OrderDao orderDao;

    public Order findAllOrder(Integer id){
        Order order = new Order();
        List<OrderItems> items = orderDao.findAllOrder(id);
        Double totalMoney = orderDao.getTotalMoney(id);
        order.setOrderItems(items);
        order.setTotalMoney(totalMoney);
        return order;
    }

    @Override
    public void addOrder(Integer uid, Integer cid, Integer getid, Integer backid, String oprices) {
        String status = "已预订";

        double oprice = Double.parseDouble(oprices);
        SysOrder order = new SysOrder();
        order.setUid(uid);
        order.setCid(cid);
        order.setGetid(getid);
        order.setBackid(backid);
        order.setOprice(oprice);
        order.setStatus(status);
        orderDao.insertSelective(order);
    }

    @Override
    public void delOrder(Integer id) {
        orderDao.delOrder(id);
    }
}
